package com.yc.sole.system.service;

import com.yc.sole.system.repository.SequenceRuleRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author yizuomin
 * @date 2023/5/6 23:25
 **/
@Service
@RequiredArgsConstructor
public class SequenceService {

    private final SequenceRuleRepository sequenceRuleRepository;

    /**
     * 获取序列号
     *
     * @param seqNoKey
     * @return
     */
    public String generateSeqNo(String seqNoKey) {
        return sequenceRuleRepository.getSequenceNo(seqNoKey);
    }
    /*public String generateSeqNo(String seqNoKey) {
        seqNoKey = CharSequenceUtil.isBlank(seqNoKey) ? "NO" : seqNoKey;
        StringBuilder str = new StringBuilder();
        String key = seqNoKey.concat(DateUtil.format(LocalDateTime.now(), "yyMMdd"));
        Long aLong = redissonService.incrementLongAndExpire("SEQUENCE:" + key, CacheTime.THREE_DAY);
        return str.append(key).append(StringUtils.leftPad(aLong.toString(), 4, "0")).toString();
    }*/
}
